package cn.edu.ldh.toolapp.slice;

import cn.edu.ldh.toolapp.ResourceTable;
import cn.edu.ldh.toolapp.util.ImgUtil;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Component;
import ohos.agp.components.Image;

public class MainAbilitySlice extends AbilitySlice {

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
        this.startInit();
    }

    //初始化组件
    private void startInit() {
        findComponentById(ResourceTable.Id_fish_item).setClickedListener(this::toFish);
        findComponentById(ResourceTable.Id_joke_item).setClickedListener(this::toJoke);
        findComponentById(ResourceTable.Id_note_item).setClickedListener(this::toNote);
        findComponentById(ResourceTable.Id_codeImgItem).setClickedListener(this::toCodeImg);
    }

    private void toCodeImg(Component component) {
        startPage(new CodeImgAbilitySlice());
    }

    private void toNote(Component component) {
        startPage(new NoteAbilitySlice());
    }

    //跳转
    private void toJoke(Component component) {
        startPage(new JokeAbilitySlice());
    }

    //跳转
    private void toFish(Component component) {
        startPage(new FishAbilitySlice());
    }

    //公共跳转方法
    private void startPage(AbilitySlice abilitySlice) {
        present(abilitySlice, new Intent());
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
